
/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package Apusic.impl;

import Apusic.ApusicPackage;
import Apusic.HttpSessionCfg;
import Apusic.HttpSessionStoreCfg;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import javax.management.ObjectName;
import org.eclipse.emf.ecore.EObject;
import com.apusic.admin.config.*;
import com.apusic.admin.*;

import cn.edu.pku.sei.ra.wrapping.CommonWrapping.WrappingEObject;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.impl.WrappingEObjectImpl;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.EObjectContainmentEListForWrapping;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.EObjectResolvingEListForWrapping;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.ImagePool;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Http Session Cfg</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link Apusic.impl.HttpSessionCfgImpl#getMaxSessionsInCache <em>Max Sessions In Cache</em>}</li>
 *   <li>{@link Apusic.impl.HttpSessionCfgImpl#getDefaultSessionTimeout <em>Default Session Timeout</em>}</li>
 *   <li>{@link Apusic.impl.HttpSessionCfgImpl#getSessionInvalidateCheckInterval <em>Session Invalidate Check Interval</em>}</li>
 *   <li>{@link Apusic.impl.HttpSessionCfgImpl#getSessionSwapCheckInterval <em>Session Swap Check Interval</em>}</li>
 *   <li>{@link Apusic.impl.HttpSessionCfgImpl#isDistributable <em>Distributable</em>}</li>
 *   <li>{@link Apusic.impl.HttpSessionCfgImpl#getSessionStoreCfg <em>Session Store Cfg</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class HttpSessionCfgImpl extends WrappingEObjectImpl implements HttpSessionCfg
{
  /**
   * The default value of the '{@link #getMaxSessionsInCache() <em>Max Sessions In Cache</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMaxSessionsInCache()
   * @generated
   * @ordered
   */
  protected static final int MAX_SESSIONS_IN_CACHE_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getMaxSessionsInCache() <em>Max Sessions In Cache</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMaxSessionsInCache()
   * @generated
   * @ordered
   */
  protected int maxSessionsInCache = MAX_SESSIONS_IN_CACHE_EDEFAULT;

  /**
   * The default value of the '{@link #getDefaultSessionTimeout() <em>Default Session Timeout</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDefaultSessionTimeout()
   * @generated
   * @ordered
   */
  protected static final int DEFAULT_SESSION_TIMEOUT_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getDefaultSessionTimeout() <em>Default Session Timeout</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDefaultSessionTimeout()
   * @generated
   * @ordered
   */
  protected int defaultSessionTimeout = DEFAULT_SESSION_TIMEOUT_EDEFAULT;

  /**
   * The default value of the '{@link #getSessionInvalidateCheckInterval() <em>Session Invalidate Check Interval</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSessionInvalidateCheckInterval()
   * @generated
   * @ordered
   */
  protected static final int SESSION_INVALIDATE_CHECK_INTERVAL_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getSessionInvalidateCheckInterval() <em>Session Invalidate Check Interval</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSessionInvalidateCheckInterval()
   * @generated
   * @ordered
   */
  protected int sessionInvalidateCheckInterval = SESSION_INVALIDATE_CHECK_INTERVAL_EDEFAULT;

  /**
   * The default value of the '{@link #getSessionSwapCheckInterval() <em>Session Swap Check Interval</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSessionSwapCheckInterval()
   * @generated
   * @ordered
   */
  protected static final int SESSION_SWAP_CHECK_INTERVAL_EDEFAULT = 0;

  /**
   * The cached value of the '{@link #getSessionSwapCheckInterval() <em>Session Swap Check Interval</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSessionSwapCheckInterval()
   * @generated
   * @ordered
   */
  protected int sessionSwapCheckInterval = SESSION_SWAP_CHECK_INTERVAL_EDEFAULT;

  /**
   * The default value of the '{@link #isDistributable() <em>Distributable</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isDistributable()
   * @generated
   * @ordered
   */
  protected static final boolean DISTRIBUTABLE_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isDistributable() <em>Distributable</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isDistributable()
   * @generated
   * @ordered
   */
  protected boolean distributable = DISTRIBUTABLE_EDEFAULT;

  /**
   * The cached value of the '{@link #getSessionStoreCfg() <em>Session Store Cfg</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSessionStoreCfg()
   * @generated
   * @ordered
   */
  protected HttpSessionStoreCfg sessionStoreCfg;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected HttpSessionCfgImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return ApusicPackage.Literals.HTTP_SESSION_CFG;
  }

  
  

  
  
  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */ 
   public boolean isForCore(Object arg0){
   	boolean result=true;
   	if(core==null) return false;
    try{
    result=true;
    }
    catch(Exception e){
      result=false;
    }
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */ 
  public List listSubCores(int featureID){
    List result=new ArrayList();
  
    HttpSessionConfig core=(HttpSessionConfig)this.getCore();
    if(core==null) 
      return result;
    switch(featureID){
    
  
  
  
  
  
  
  }
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */ 
  public EClass getChildClassMap(Object object){
    ApusicPackage pack=ApusicPackage.eINSTANCE;	
  
  
  
  
  
  
    return null;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getMaxSessionsInCache()
  {
        Object result=null;
        HttpSessionConfig core=(HttpSessionConfig)getCore();
        if(core==null) return maxSessionsInCache;	
        try
{
maxSessionsInCache=core.getMaxSessionsInCache();
}
catch(Exception e)
{
  maxSessionsInCache = -1;
}
    return maxSessionsInCache; 
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMaxSessionsInCache(int newMaxSessionsInCache)
  {
    int oldMaxSessionsInCache = maxSessionsInCache;
    maxSessionsInCache = newMaxSessionsInCache;
        	
      HttpSessionConfig core=(HttpSessionConfig)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ApusicPackage.HTTP_SESSION_CFG__MAX_SESSIONS_IN_CACHE, oldMaxSessionsInCache, maxSessionsInCache));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getDefaultSessionTimeout()
  {
        Object result=null;
        HttpSessionConfig core=(HttpSessionConfig)getCore();
        if(core==null) return defaultSessionTimeout;	
        try
{
defaultSessionTimeout=core.getDefaultSessionTimeout();
}
catch(Exception e)
{
  defaultSessionTimeout = -1;
}
    return defaultSessionTimeout; 
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDefaultSessionTimeout(int newDefaultSessionTimeout)
  {
    int oldDefaultSessionTimeout = defaultSessionTimeout;
    defaultSessionTimeout = newDefaultSessionTimeout;
        	
      HttpSessionConfig core=(HttpSessionConfig)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ApusicPackage.HTTP_SESSION_CFG__DEFAULT_SESSION_TIMEOUT, oldDefaultSessionTimeout, defaultSessionTimeout));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getSessionInvalidateCheckInterval()
  {
        Object result=null;
        HttpSessionConfig core=(HttpSessionConfig)getCore();
        if(core==null) return sessionInvalidateCheckInterval;	
        try
{
sessionInvalidateCheckInterval=core.getSessionInvalidateCheckInterval();
}
catch(Exception e)
{
  sessionInvalidateCheckInterval = -1;
}
    return sessionInvalidateCheckInterval; 
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSessionInvalidateCheckInterval(int newSessionInvalidateCheckInterval)
  {
    int oldSessionInvalidateCheckInterval = sessionInvalidateCheckInterval;
    sessionInvalidateCheckInterval = newSessionInvalidateCheckInterval;
        	
      HttpSessionConfig core=(HttpSessionConfig)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ApusicPackage.HTTP_SESSION_CFG__SESSION_INVALIDATE_CHECK_INTERVAL, oldSessionInvalidateCheckInterval, sessionInvalidateCheckInterval));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getSessionSwapCheckInterval()
  {
        Object result=null;
        HttpSessionConfig core=(HttpSessionConfig)getCore();
        if(core==null) return sessionSwapCheckInterval;	
        try
{
sessionSwapCheckInterval=core.getSessionSwapCheckInterval();
}
catch(Exception e)
{
  sessionSwapCheckInterval = -1;
}
    return sessionSwapCheckInterval; 
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSessionSwapCheckInterval(int newSessionSwapCheckInterval)
  {
    int oldSessionSwapCheckInterval = sessionSwapCheckInterval;
    sessionSwapCheckInterval = newSessionSwapCheckInterval;
        	
      HttpSessionConfig core=(HttpSessionConfig)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ApusicPackage.HTTP_SESSION_CFG__SESSION_SWAP_CHECK_INTERVAL, oldSessionSwapCheckInterval, sessionSwapCheckInterval));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isDistributable()
  {
        Object result=null;
        HttpSessionConfig core=(HttpSessionConfig)getCore();
        if(core==null) return distributable;	
        try
{
distributable=core.isDistributable();
}
catch(Exception e)
{
  distributable = false;
}
    return distributable; 
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDistributable(boolean newDistributable)
  {
    boolean oldDistributable = distributable;
    distributable = newDistributable;
        	
      HttpSessionConfig core=(HttpSessionConfig)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ApusicPackage.HTTP_SESSION_CFG__DISTRIBUTABLE, oldDistributable, distributable));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public HttpSessionStoreCfg getSessionStoreCfg()
  {
    if (sessionStoreCfg != null && sessionStoreCfg.eIsProxy())
    {
      InternalEObject oldSessionStoreCfg = (InternalEObject)sessionStoreCfg;
      sessionStoreCfg = (HttpSessionStoreCfg)eResolveProxy(oldSessionStoreCfg);
      if (sessionStoreCfg != oldSessionStoreCfg)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, ApusicPackage.HTTP_SESSION_CFG__SESSION_STORE_CFG, oldSessionStoreCfg, sessionStoreCfg));
      }
    }
        Object result=null;
        HttpSessionConfig core=(HttpSessionConfig)getCore();
        if(core==null) return sessionStoreCfg;	
        try
{
    result = core.getSessionStore();
     HttpSessionStoreCfgImpl sessionStore =new HttpSessionStoreCfgImpl();
     sessionStore.setCore(result);
     result=sessionStore;
     
}
catch(Exception e)
{
  result = null;
}
        sessionStoreCfg=(result instanceof EObject)?(HttpSessionStoreCfg)result:(HttpSessionStoreCfg)ImagePool.find(result);
        	
    return sessionStoreCfg; 
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public HttpSessionStoreCfg basicGetSessionStoreCfg()
  {
    return sessionStoreCfg;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setSessionStoreCfg(HttpSessionStoreCfg newSessionStoreCfg)
  {
    HttpSessionStoreCfg oldSessionStoreCfg = sessionStoreCfg;
    sessionStoreCfg = newSessionStoreCfg;
        	
      HttpSessionConfig core=(HttpSessionConfig)getCore();
      if(core==null) return;
      	
        
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, ApusicPackage.HTTP_SESSION_CFG__SESSION_STORE_CFG, oldSessionStoreCfg, sessionStoreCfg));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case ApusicPackage.HTTP_SESSION_CFG__MAX_SESSIONS_IN_CACHE:
        return new Integer(getMaxSessionsInCache());
      case ApusicPackage.HTTP_SESSION_CFG__DEFAULT_SESSION_TIMEOUT:
        return new Integer(getDefaultSessionTimeout());
      case ApusicPackage.HTTP_SESSION_CFG__SESSION_INVALIDATE_CHECK_INTERVAL:
        return new Integer(getSessionInvalidateCheckInterval());
      case ApusicPackage.HTTP_SESSION_CFG__SESSION_SWAP_CHECK_INTERVAL:
        return new Integer(getSessionSwapCheckInterval());
      case ApusicPackage.HTTP_SESSION_CFG__DISTRIBUTABLE:
        return isDistributable() ? Boolean.TRUE : Boolean.FALSE;
      case ApusicPackage.HTTP_SESSION_CFG__SESSION_STORE_CFG:
        if (resolve) return getSessionStoreCfg();
        return basicGetSessionStoreCfg();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case ApusicPackage.HTTP_SESSION_CFG__MAX_SESSIONS_IN_CACHE:
        setMaxSessionsInCache(((Integer)newValue).intValue());
        return;
      case ApusicPackage.HTTP_SESSION_CFG__DEFAULT_SESSION_TIMEOUT:
        setDefaultSessionTimeout(((Integer)newValue).intValue());
        return;
      case ApusicPackage.HTTP_SESSION_CFG__SESSION_INVALIDATE_CHECK_INTERVAL:
        setSessionInvalidateCheckInterval(((Integer)newValue).intValue());
        return;
      case ApusicPackage.HTTP_SESSION_CFG__SESSION_SWAP_CHECK_INTERVAL:
        setSessionSwapCheckInterval(((Integer)newValue).intValue());
        return;
      case ApusicPackage.HTTP_SESSION_CFG__DISTRIBUTABLE:
        setDistributable(((Boolean)newValue).booleanValue());
        return;
      case ApusicPackage.HTTP_SESSION_CFG__SESSION_STORE_CFG:
        setSessionStoreCfg((HttpSessionStoreCfg)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case ApusicPackage.HTTP_SESSION_CFG__MAX_SESSIONS_IN_CACHE:
        setMaxSessionsInCache(MAX_SESSIONS_IN_CACHE_EDEFAULT);
        return;
      case ApusicPackage.HTTP_SESSION_CFG__DEFAULT_SESSION_TIMEOUT:
        setDefaultSessionTimeout(DEFAULT_SESSION_TIMEOUT_EDEFAULT);
        return;
      case ApusicPackage.HTTP_SESSION_CFG__SESSION_INVALIDATE_CHECK_INTERVAL:
        setSessionInvalidateCheckInterval(SESSION_INVALIDATE_CHECK_INTERVAL_EDEFAULT);
        return;
      case ApusicPackage.HTTP_SESSION_CFG__SESSION_SWAP_CHECK_INTERVAL:
        setSessionSwapCheckInterval(SESSION_SWAP_CHECK_INTERVAL_EDEFAULT);
        return;
      case ApusicPackage.HTTP_SESSION_CFG__DISTRIBUTABLE:
        setDistributable(DISTRIBUTABLE_EDEFAULT);
        return;
      case ApusicPackage.HTTP_SESSION_CFG__SESSION_STORE_CFG:
        setSessionStoreCfg((HttpSessionStoreCfg)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case ApusicPackage.HTTP_SESSION_CFG__MAX_SESSIONS_IN_CACHE:
        return maxSessionsInCache != MAX_SESSIONS_IN_CACHE_EDEFAULT;
      case ApusicPackage.HTTP_SESSION_CFG__DEFAULT_SESSION_TIMEOUT:
        return defaultSessionTimeout != DEFAULT_SESSION_TIMEOUT_EDEFAULT;
      case ApusicPackage.HTTP_SESSION_CFG__SESSION_INVALIDATE_CHECK_INTERVAL:
        return sessionInvalidateCheckInterval != SESSION_INVALIDATE_CHECK_INTERVAL_EDEFAULT;
      case ApusicPackage.HTTP_SESSION_CFG__SESSION_SWAP_CHECK_INTERVAL:
        return sessionSwapCheckInterval != SESSION_SWAP_CHECK_INTERVAL_EDEFAULT;
      case ApusicPackage.HTTP_SESSION_CFG__DISTRIBUTABLE:
        return distributable != DISTRIBUTABLE_EDEFAULT;
      case ApusicPackage.HTTP_SESSION_CFG__SESSION_STORE_CFG:
        return sessionStoreCfg != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (maxSessionsInCache: ");
    result.append(maxSessionsInCache);
    result.append(", defaultSessionTimeout: ");
    result.append(defaultSessionTimeout);
    result.append(", sessionInvalidateCheckInterval: ");
    result.append(sessionInvalidateCheckInterval);
    result.append(", sessionSwapCheckInterval: ");
    result.append(sessionSwapCheckInterval);
    result.append(", distributable: ");
    result.append(distributable);
    result.append(')');
    return result.toString();
  }

} //HttpSessionCfgImpl
